package com.futvan.z.system.zwarning;
import com.futvan.z.framework.common.bean.Code;
import com.futvan.z.framework.common.bean.Result;
import com.futvan.z.framework.core.z;
import com.futvan.z.framework.util.StringUtil;
import com.futvan.z.framework.util.WarningUtil;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import com.futvan.z.framework.core.SuperAction;
import com.futvan.z.system.zwarning.ZwarningService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@Controller
public class ZwarningAction extends SuperAction{
	@Autowired
	private ZwarningService zwarningService;

	/**
	 * 根据预警记录ID，发送预警信息
	 * @param bean
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/SendWarningMsg")
	public @ResponseBody Result getListBySQL(@RequestParam HashMap<String, String> bean) throws Exception {
		Result result = new Result();
		String zid = bean.get("zid");
		if(z.isNotNull(zid)) {
			result = WarningUtil.SendWarningMsg(zid);
		}else {
			result.setCode(Code.ERROR);
			result.setMsg("预警ID不可为空");
		}
		return result;
	}


	/**
	 * 启动预警
	 * @param bean
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/start_warning")
	public @ResponseBody Result start_warning(@RequestParam HashMap<String, String> bean) throws Exception {
		Result result = new Result();
		String zids = bean.get("zids");
		if(z.isNotNull(zids)) {
			result = WarningUtil.start_warning(zids);
		}else {
			result.setCode(Code.ERROR);
			result.setMsg("预警ID不可为空");
		}
		return result;
	}

	/**
	 * 关闭预警
	 * @param bean
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/close_warning")
	public @ResponseBody Result close_warning(@RequestParam HashMap<String, String> bean) throws Exception {
		Result result = new Result();
		String zids = bean.get("zids");
		if(z.isNotNull(zids)) {
			result = WarningUtil.close_warning(zids);
		}else {
			result.setCode(Code.ERROR);
			result.setMsg("预警ID不可为空");
		}
		return result;
	}
}
